package com.docHunt.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.docHunt.BO.DoctorBO;
import com.docHunt.DTO.DoctorDTO;

public class DoctorInfoAction extends BaseAction {

	@Autowired
	DoctorBO doctorBO;

	private static final long serialVersionUID = 1L;
	private Logger logger = Logger.getLogger(DoctorInfoAction.class);
		
	public DoctorDTO doctorDTO;
	public List<String> genderList;

	public String init() throws Exception {

		logger.info("DoctorInfoAction :: init - method start");
		genderList = new ArrayList<String>();
		genderList.add("Male");
		genderList.add("Female");

		return SUCCESS;
	}

	public String addDoctorInfo() throws Exception {

		logger.info("DoctorInfoAction :: addUser - method start");

		doctorBO.addDoctorInfo(doctorDTO);
		
		return SUCCESS;

	}

	public void validate() {

		if (doctorDTO.getFirstName() == null || doctorDTO.getFirstName().equals("")) {
			addActionError("First Name is required");
		}

		if (doctorDTO.getLastName() == null || doctorDTO.getLastName().equals("")) {
			addActionError("Last Name is required");
		}

		if (doctorDTO.getBirthDate() == null || doctorDTO.getBirthDate().equals("")) {
			addActionError("Birth Date is required");
		}

		if (doctorDTO.getMobileNo() == null || doctorDTO.getMobileNo().equals("")) {
			addActionError("Mobile Number is required");
		}
	}
	
	public DoctorDTO getDoctorDTO() {
		return doctorDTO;
	}

	public void setDoctorDTO(DoctorDTO doctorDTO) {
		this.doctorDTO = doctorDTO;
	}

	public List<String> getGenderList() {
		return genderList;
	}

	public void setGenderList(List<String> genderList) {
		this.genderList = genderList;
	}
}